package com.example.dc.Controller;

import com.example.dc.utils.AliOSSUtils;
import com.example.dc.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;

@Slf4j
@RestController("/load")
public class UploadControll {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/loadFile")
    public Result upload(MultipartFile file) throws IOException {
        try{
            String url= aliOSSUtils.upload(file);
            System.out.println(url);
            return Result.success(url);
        }
        catch (Exception err){
            return Result.systemError();
        }
    }


}
